<!DOCTYPE html>
<html>
<head>
    <title>财务复核打印</title>
<#include "../common/common.ftl"/>
    <link rel="stylesheet" href="/style/contractForm.css" media="all">

</head>
<body style="overflow-y: hidden;">
<div class="layui-fluid">
    <blockquote class="layui-elem-quote layui-bg-white">
        财务表格【姓名：<span class="jmdf-color-red">${(contract.name)!}</span>】【协议编号：<span
            class="jmdf-color-red">${(contract.contractCode)!}</span>】
    </blockquote>
    <div class="layui-row layui-col-space15">
        <div class="layui-col-lg4 layui-col-md4">
            <div class="layui-card">
                <div class="layui-card-header">
                    财务复核状态：
                <#if contract.financeCheckStatus == 1><span class="jmdf-color-red">未复核</span></#if>
                <#if contract.financeCheckStatus == 2><span class="jmdf-color-green">已复核</span></#if>
                <#if contract.financeCheckStatus == 3><span class="jmdf-color-blue">数据退回</span></#if>
                </div>
            <#if (contract.financeSettleStatus ?? && contract.financeSettleStatus != 2)>
                <div class="layui-card-body">
                    <button class="layui-btn layui-btn-fluid checkStatus
                    <#if contract.financeCheckStatus == 2> layui-btn-danger</#if>" contractId="${(contract.id)!}">
                        <#if contract.financeCheckStatus == 2>设置为财务退回<#else>设置为已复核</#if>
                    </button>
                </div>
            </#if>
                <div class="layui-card-body">
                    <form class="layui-form" id="financeForm">
                        <input type="hidden" name="contractId" value="${(contract.id)!}"/>
                        <div class="layui-card">
                        <#if (contract.zzResultArea?? && contract.zzResultArea < 0)>
                            注:<span class="jmdf-color-red">该家庭实际选房置换结果小于产权调换面积</span>
                        </#if>
                            <div class="layui-card-header">补助费发放标准调整</div>
                            <#--<div class="layui-form-item">
                                <button type="button" class="layui-btn calBzMoney">计算补助费标准</button>
                            </div>-->
                            <div class="layui-form-item jmdf-color-red zzgdMoneyHtml"></div>
                            <div class="layui-form-item jmdf-color-red zxgdMoneyHtml"></div>
                            <div class="layui-form-item jmdf-color-red textHeml"></div>
                            <div class="layui-form-item">
                                <#--<div class="layui-col-xs12">
                                    <div class="layui-inline">
                                        <label class="layui-form-labelLong">住宅过渡补助费：<span
                                                class="jmdf-color-red">(元/月)</span></label>
                                        <div class="layui-input-blockRight">
                                            <input type="text" style="width: 150px" class="layui-input"
                                                   lay-verify="bigDecimal" name="zzgdMoney"
                                                   value="${(contract.zzgdMoney)!}"/>
                                        </div>
                                    </div>
                                </div>-->
                                <div class="layui-col-xs12">
                                    <div class="layui-inline">
                                        <label class="layui-form-labelLong">装修过渡补助费：<span
                                                class="jmdf-color-red">(元/月)</span></label>
                                        <div class="layui-input-blockRight">
                                            <input type="text" style="width: 150px;background-color: #9BC2E6" class="layui-input"
                                                   lay-verify="bigDecimal" name="zxgdMoney" readonly
                                                   value="${(contract.zxgdMoney)!}"/>
                                        </div>
                                    </div>
                                </div>
                                <div class="layui-col-xs12">
                                    <div class="layui-inline">
                                        <label class="layui-form-labelLong">应缴交金额：<span
                                                class="jmdf-color-red">(元)</span></label>
                                        <div class="layui-input-blockRight">
                                            <input type="text" style="width: 150px;background-color: #9BC2E6" class="layui-input"
                                                   lay-verify="bigDecimal" name="resultMoney" readonly
                                                   value="${(contract.resultMoney)!}"/>
                                        </div>
                                    </div>
                                </div>
                                <div class="layui-col-xs12">
                                    <div class="layui-inline">
                                        <label class="layui-form-labelLong">其他金额：<span class="jmdf-color-red">(元)</span></label>
                                        <div class="layui-input-blockRight">
                                            <input type="text" style="width: 150px" class="layui-input"
                                                   lay-verify="bigDecimal" name="otherMoney"
                                                   value="${(contract.otherMoney)!}"/>
                                        </div>
                                    </div>
                                </div>
                                <div class="layui-col-xs12">
                                    <div class="layui-inline">
                                        <label class="layui-form-labelLong">财务备注：</label>
                                        <div class="layui-input-blockRight">
                                            <textarea class="layui-textarea" cols="180" rows="5"
                                                      name="financeMemo">${(contract.financeMemo)!}</textarea>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </form>
                </div>
            <#if contract.financeCheckStatus ?? && contract.financeCheckStatus  != 2>
                <div class="layui-card-body">
                    <button class="layui-btn layui-btn-fluid" lay-submit="" lay-filter="submit">保存</button>
                </div>
            </#if>
            </div>
        </div>
        <div class="layui-col-lg8 layui-col-md8">
            <div class="layui-card">
                <div class="layui-tab layui-tab-brief" id="finance">
                    <ul class="layui-tab-title">
                        <li source="/pdf/print/settlementPDF?contractId=${(contract.id)!}" class="layui-this">财务结算表</li>
                    <#if (contract.shouldHandInMoney lt 0)>
                        <li source="/pdf/print/handInMoneyPrintPDF?contractId=${(contract.id)!}">房屋缴款通知书</li>
                    <#--<li source="/pdf/print/paymentPDF?contractId=${(contract.id)!}">缴款清单</li>-->
                    </#if>
                        <li source="/pdf/print/handInMoneyWxjPrintPDF?contractId=${(contract.id)!}">维修基金缴款通知书</li>
                        <#--<#if (contract.chooseHouseQiFangAreaTotal ?? && contract.chooseHouseQiFangAreaTotal gt 0)>-->
                        <#--<li source="/pdf/print/advanceTakeHousePrintPDF?contractId=${(contract.id)!}">申请提前交房呈阅件</li>-->
                    <#--</#if>-->
                    </ul>
                    <iframe id="printIframe" style="width: 100%;height: 730px;margin-top: 10px"></iframe>
                </div>
            </div>
        </div>
    </div>
</div>
</body>
<script src="/layui/layui.js" charset="utf-8"></script>
<script src="/bigDecimal/BigDecimal-all-last.js"></script>
<script src="/bigDecimal/BigDecimal-all-last.min.js"></script>
<script src="/bigDecimal/common.js"></script>
<script>
    layui.config({
        base: '/modules/' //静态资源所在路径
    }).use(['jquery', 'layer', 'element', 'jmdf', 'verify', 'form'], function () {
        var $ = layui.jquery, form = layui.form, jmdf = layui.jmdf, layer = layui.layer, verify = layui.verify, element = layui.element;

//        打印链接调用
        function openPdf(source) {
            var url = source + "#toolbar=0";
            $("#printIframe").attr("src", url);
        }

        $("#finance li").click(function () {
            var source = $(this).attr("source");
            openPdf(source);
        });
        openPdf($("#finance li").attr("source"));


        //设置复核状态
        $(".checkStatus").click(function () {
            var msg = '${contract.financeCheckStatus}' == 2 ? "财务退回" : "已复核";
            layer.open({
                title: false, shade: 0.5, content: "确认设置为" + msg + "吗？", btn: ['确定', '取消'], closeBtn: 0, btnAlign: 'c'
                , yes: function (index) {
                    $.get("checkStatus", {
                        contractId: '${(contract.id)!}',
                        _time: new Date().getTime()
                    }, function (data) {
                        if (data.code == "0001") {//成功
                            parent.loadData();
                            layer.msg(data.message, {anim: 0, icon: 1, time: 500}, function () {
                                location.reload();
                            });
                        } else {//失败
                            layer.msg(data.message, {anim: 6, icon: 2, time: 3000});
                        }
                        layer.close(index);
                    });
                }
            });
        });

        //保存住宅、装修过度补助费
        form.on('submit(submit)', function (data) {
            $.ajax({
                url: "setTransitionMoney",
                type: "post",
                data: $("#financeForm").serialize(),
                success: function (data) {
                    if (data.code == "0001") {
                        layer.msg(data.message, {anim: 0, icon: 1, time: 500}, function () {
                            location.reload();
                        });
                    } else {//失败
                        layer.msg(data.message, {anim: 6, icon: 2, time: 3000});
                    }
                }
            });
            return false;
        });

        function calBzMoney() {
            var zzgdMoney = new BigDecimal("0");
            var zzgdMoneyHtml = "";
            var zxgdMoney = new BigDecimal("0");
            var zxgdMoneyHtml = "";
            var textHeml = "计算结果仅供参考，最终结果请以征迁协议过渡费实际发放金额为准！";
            $(".textHeml").html(textHeml);

            //得到抵扣后含储物间总选房面积resultArea
            //扩购住宅过渡补助费标准为产权调换乘以6
        <#if (contract.zzResultArea ??  && contract.zzResultArea >= 0 )>
            zzgdMoney = bigMulBigByArea("${(contract.propertyChangeArea)!0}", "${(contract.parameter.gdbzPrice)!0}", 2);
            if (zzgdMoney > 6500) {//洛阳旧项目补助标准最大不能超过6500元/月
                zzgdMoney = new BigDecimal("6500");
            }
            zzgdMoneyHtml = "住宅过渡补助费标准:${(contract.propertyChangeArea)!0}㎡×${(contract.parameter.gdbzPrice)!0}元/㎡,最大不超6500元/月！";
            zxgdMoney = bigMulBigByArea("${(contract.propertyChangeArea)!0}", "${(contract.parameter.gdbzPrice)!0}", 2);
            if (zxgdMoney > 6500) {//洛阳旧项目补助标准最大不能超过6500元/月
                zxgdMoney = new BigDecimal("6500");
            }
            zxgdMoneyHtml = "装修过渡补助费标准:${(contract.propertyChangeArea)!0}㎡×${(contract.parameter.gdbzPrice)!0}元/㎡,最大不超6500元/月！";
            //已选面积>产权调换面积，为产权调换乘以6
        <#else>
            //如果产权调换面积>=含储物间抵扣后总面积，则抵扣后面积乘以6
            <#if (contract.propertyChangeArea ?? && resultArea ?? &&contract.propertyChangeArea gt resultArea)>
                <#if (contract.isJiSuan ??  && contract.isJiSuan == 1 )>
                    zzgdMoney = bigMulBigByArea("${(contract.propertyChangeArea)!0}", "${(contract.parameter.gdbzPrice)!0}", 2);
                    zzgdMoneyHtml = "住宅过渡补助费标准:${(contract.propertyChangeArea)!0}㎡×${(contract.parameter.gdbzPrice)!0}元/㎡,最大不超6500元/月！";
                <#else>
                    zzgdMoney = bigMulBigByArea("${(resultArea)!0}", "${(contract.parameter.gdbzPrice)!0}", 2);
                    zzgdMoneyHtml = "住宅过渡补助费标准:${(resultArea)!0}㎡×${(contract.parameter.gdbzPrice)!0}元/㎡,最大不超6500元/月！";
                </#if>
                zxgdMoney = bigMulBigByArea("${(resultArea)!0}", "${(contract.parameter.gdbzPrice)!0}", 2);
                zxgdMoneyHtml = "装修过渡补助费标准:${(resultArea)!0}㎡×${(contract.parameter.gdbzPrice)!0}元/㎡,最大不超6500元/月！";
            <#else>
                //结算时住宅过渡全部产权调换乘以6；装修过渡已使用产权乘以6
                zzgdMoney = bigMulBigByArea("${(contract.propertyChangeArea)!0}", "${(contract.parameter.gdbzPrice)!0}", 2);
                zzgdMoneyHtml = "住宅过渡补助费标准:${(contract.propertyChangeArea)!0}㎡×${(contract.parameter.gdbzPrice)!0}元/㎡,最大不超6500元/月！";
                zxgdMoney = bigMulBigByArea("${(contract.propertyChangeArea)!0}", "${(contract.parameter.gdbzPrice)!0}", 2);
                zxgdMoneyHtml = "装修过渡补助费标准:${(contract.propertyChangeArea)!0}㎡×${(contract.parameter.gdbzPrice)!0}元 /㎡,最大不超6500元/月！";

            </#if>
        </#if>
            $("input:text[name='zzgdMoney']").val(zzgdMoney);
            $(".zzgdMoneyHtml").html(zzgdMoneyHtml);
            $("input:text[name='zxgdMoney']").val(zxgdMoney);
            $(".zxgdMoneyHtml").html(zxgdMoneyHtml);

        <#--var useZggmArea = new BigDecimal("0");-->
        <#--var allZggmArea = new BigDecimal("0");-->
        <#--var shouldmoney = new BigDecimal("0");-->
        <#--var zqResultMoneyHtml = "";-->
        <#--allZggmArea=bigSubBig(${(contract.limitHouseAreaTotal)!0},${(contract.propertyChangeArea)!0},2);-->
        <#--useZggmArea=bigSubBig(allZggmArea,${(contract.syzggmArea)!0},2);-->
        <#--shouldmoney=bigMulBigByArea(bigDivBig(useZggmArea,allZggmArea,6),${(contract.resultMoney)!0},2);-->
        <#--<#if (contract.isJiSuan ??  && contract.isJiSuan == 1 )>-->
        <#--zqResultMoneyHtml = "本次应缴交金额为全部缴清：${(contract.resultMoney)!0}元！"-->
        <#--<#else>-->
        <#--<#if (contract.sycqdhArea ?? &&contract.sycqdhArea >0)>-->
        <#--zqResultMoneyHtml = "本次未使用照顾购买，应缴交金额无需结清！"-->
        <#--<#else>-->
        <#--<#if (contract.syzggmArea ?? && contract.syzggmArea < 65)>-->
        <#--zqResultMoneyHtml = "本次剩余照顾购买<65，应缴交金额需全部缴清：${(contract.resultMoney)!0}元"-->
        <#--<#else>-->
        <#--zqResultMoneyHtml = "本次使用照顾购买面积为:"+useZggmArea+";"+"应缴交金额："+ useZggmArea+"➗"+allZggmArea+"✖ ${(contract.resultMoney)!0}＝"+shouldmoney;-->

        <#--</#if>-->
        <#--</#if>-->
        <#--</#if>-->
        <#--$(".zqResultMoneyHtml").html(zqResultMoneyHtml);-->

        }

        $(".calBzMoney").click(function () {
            calBzMoney();
        });
    });

</script>
</html>
